<cfinclude template="/ecada/header.cfm">
<cfquery name = "Halted" datasource = "exp" result="test">
	SELECT * 
	FROM experiment
	WHERe StatusID = (SELECT id
						FROM expstatus
						WHERE Status = 'Halted')
	AND (userid = #session.id#
		OR GroupID IN 
					(
						SELECT gu.GroupID
						FROM groupusers gu
						WHERE gu.UserID = #session.id#
					)
		)
	ORDER BY experiment.id
</cfquery>
<cfoutput>
	Query Time: #test.executiontime#<br><br>
</cfoutput>
<cfif Halted.recordcount eq 0>
	<cfoutput>
		There are no halted experiments
	</cfoutput>
<cfelse>
	<!--- display all completed experiments --->
	<cfoutput>	
		<h2>Halted experiments</h2>
		
		<cfloop query = "Halted">
			<table border="1">
				<cfquery datasource="exp" name="numparticipants">
						SELECT count(id) as cnt
						FROM participant
						WHERE expid = #Halted.id#
				</cfquery>
				<tr>
					<th colspan=2>Experiment Details</th>
				</tr>
				<tr>
					<td colspan=2>#Halted.title#</td>
				</tr>
				<tr>
					<td colspan=2><p style="width: 400px;">#Halted.description#</p></td>
				</tr>
				<tr>
					<td >Maximum Participants </td>
					<td>#Halted.maxpart#</td>
				</tr>
				<tr>
					<td>Number of Participants</td>
					<td> #numparticipants.cnt#</td>
				</tr>
				<tr>
					<td>Start date: </td>
					<td>#Halted.startDate#</td>
				</tr>
				<tr>
					<td>End date:</td>
					<td>#Halted.endDate#</td>
				</tr>
				<tr>
					<td>Click to see more detail </td>
					<td>
						<a href="/ecada/viewexp/expdetail.cfm?id=#Halted.id#">Detail</a>
					</td>
				</tr>
				<tr>
					<td>
						Click to resume this experiment.
					</td>
					<td>
						<form method="post" action="experimentClose.cfm">
							<input type = "hidden" name = "id" value="#id#">
							<input type="hidden" value="0" name="close">
							<input type = "submit" value="Resume experiment">
						</form>
					</td>
				</tr>
				<tr>
					<td>
						Click to reset this experiment.
					</td>
					<td>
						<form method="post" action="experimentClose.cfm">
							<input type = "hidden" name = "id" value="#id#">
							<input type="hidden" value="0" name="close">
							<input type = "submit" value="Reset experiment">
						</form>
					</td>
				</tr>
				<tr>
					<td>
						Click to see non-anonymous paticipants.
					</td>
					<td>
						<form method="post" action="experimentClose.cfm">
							<input type = "hidden" name = "id" value="#id#">
							<input type="hidden" value="0" name="close">
							<input type = "submit" value="View Participants">
						</form>
					</td>
				</tr>
			</table>
			<br>
			<br>
		</cfloop>
	</cfoutput>
</cfif>
<cfinclude template="/ecada/footer.cfm">
